﻿using Studio77.RuneMaster.Entities;
using Studio77.RuneMaster.Entities.GameRecord;
using System;
using System.Collections.Generic;
using System.IO.IsolatedStorage;
using System.Linq;
using System.Text;

namespace Studio77.RuneMaster.Core
{
    public class StageManager
    {
        public static StageManager Instance = new StageManager();

        //keys
        private const string MODE_UNLOCK_STATUS_KEY = "ModeLockStatusKey";
        private const string STAGE_UNLOCK_STATUS_KEY = "StageUnlockStatusKey";
        private const string LAST_STAGE_INDEX_KEY = "LastStageKey";
        private const string IS_PLAY_BACKGROUND_KEY = "isPlayBackgroundKey";
        private const string IS_PLAY_SOUND_KEY = "isPlaySoundKey";
        private const string TOTALGKEY = "TotalGKey";
        private const string SAVED_GAME_RECORD = "savedGameRecordKey";
        private const string GAME_HIGHLIGHTS_KEY = "gameHighlightsKey";

        private const string LAUNCH_COUNT = "launchCount";
        private const string MARKET_COMMENT = "marketComment";
        private const string NEW_USER_TASK_KEY = "newUserTaskKey";

        private const string LAST_FULLSCREEN_DATE_KEY = "LAST_FULLSCREEN_DATE";

        public bool TurnMoka = true;

        /// <summary>
        /// 当前游戏模式
        /// </summary>
        public string CurrentGameMode = "e";

        /// <summary>
        /// 当前游戏关卡
        /// </summary>
        public string CurrentStageIndex = "1";

        /// <summary>
        /// 当前游戏子关卡
        /// </summary>
        public int CurrentSubStageIndex = 1;

        /// <summary>
        /// 生命
        /// </summary>
        public int CurrentRestartChange = 3;

        /// <summary>
        /// 当前游戏中使用的道具信息
        /// </summary>
        public Dictionary<int, ToolSlotInfo> CurrentToolSlotInfo;

        /// <summary>
        /// 当前已经使用的道具信息
        /// </summary>
        public Dictionary<int, ToolType> CurrentUsedTool;

        private StageManager()
        {
            //初始化Slot
            CurrentToolSlotInfo = new Dictionary<int, ToolSlotInfo>();
            CurrentToolSlotInfo.Add(0, null);
            CurrentToolSlotInfo.Add(1, null);
            CurrentToolSlotInfo.Add(2, null);
            CurrentToolSlotInfo.Add(3, null);

            CurrentUsedTool = new Dictionary<int, ToolType>();
            CurrentUsedTool.Add(0, ToolType.NoTool);
            CurrentUsedTool.Add(1, ToolType.NoTool);
            CurrentUsedTool.Add(2, ToolType.NoTool);
        }

        /// <summary>
        /// 清空使用的道具
        /// </summary>
        public void ClearUsedTool()
        {
            CurrentUsedTool[0] = ToolType.NoTool;
            CurrentUsedTool[1] = ToolType.NoTool;
            CurrentUsedTool[2] = ToolType.NoTool;
        }

        public void Init()
        {
            InitStageInfos();
            InitToolInfos();
            InitHistoryData();
        }

        public Dictionary<ToolType, ToolInfo> ToolInfos { get; set; }

        /// <summary>
        /// 游戏关卡信息
        /// key:e_1_1
        /// </summary>
        public Dictionary<string, StageInfo> StageInfos { get; set; }

        /// <summary>
        /// 存储关卡解锁信息
        /// key:e_1 e_2 n_1
        /// </summary>
        public Dictionary<string, bool> StageUnlockStatus { get; set; }

        /// <summary>
        /// 储存Mode解锁信息
        /// e-easy, n-normal, h-hard
        /// </summary>
        public Dictionary<string, bool> ModeUnlockStatus { get; set; }

        private string lastFullScreenDate = "XXXXXX";
        /// <summary>
        /// 上一次显示全屏广告的日期
        /// </summary>
        public string LastFullScreenDate
        {
            get
            {
                return lastFullScreenDate;
            }
            set
            {
                lastFullScreenDate = value;
                IsolatedStorageSettings.ApplicationSettings[LAST_FULLSCREEN_DATE_KEY] = lastFullScreenDate;
                IsolatedStorageSettings.ApplicationSettings.Save();
            }
        }

        private int launchCount = 1;
        public int LaunchCount
        {
            get
            {
                return launchCount;
            }
            set
            {
                launchCount = value;
                IsolatedStorageSettings.ApplicationSettings[LAUNCH_COUNT] = launchCount;
                IsolatedStorageSettings.ApplicationSettings.Save();
            }
        }

        private bool isDoNewUserTask = false;
        public bool IsDoNewUserTask
        {
            get
            {
                return isDoNewUserTask;
            }
            set
            {
                isDoNewUserTask = value;
                IsolatedStorageSettings.ApplicationSettings[NEW_USER_TASK_KEY] = isDoNewUserTask;
                IsolatedStorageSettings.ApplicationSettings.Save();
            }
        }

        private bool isCommented = false;
        public bool IsCommented
        {
            get
            {
                return isCommented;
            }
            set
            {
                isCommented = value;
                IsolatedStorageSettings.ApplicationSettings[MARKET_COMMENT] = isCommented;
                IsolatedStorageSettings.ApplicationSettings.Save();
            }
        }

        private bool isPlaySound = true;

        /// <summary>
        /// 是否播放音效
        /// </summary>
        public bool IsPlaySound
        {
            get
            {
                return isPlaySound;
            }
            set
            {
                isPlaySound = value;
                IsolatedStorageSettings.ApplicationSettings[IS_PLAY_SOUND_KEY] = isPlaySound;
                IsolatedStorageSettings.ApplicationSettings.Save();
            }
        }

        private bool isPlayBackground = true;
        /// <summary>
        /// 是否播放背景音乐
        /// </summary>
        public bool IsPlayBackground
        {
            get
            {
                return isPlayBackground;
            }
            set
            {
                isPlayBackground = value;
                IsolatedStorageSettings.ApplicationSettings[IS_PLAY_BACKGROUND_KEY] = isPlayBackground;
                IsolatedStorageSettings.ApplicationSettings.Save();
            }
        }

        private string lastStage;
        /// <summary>
        /// 上一个关卡
        /// </summary>
        public string LastStage
        {
            get
            {
                return lastStage;
            }
            set
            {
                lastStage = value;
                IsolatedStorageSettings.ApplicationSettings[LAST_STAGE_INDEX_KEY] = lastStage;
                IsolatedStorageSettings.ApplicationSettings.Save();
            }
        }

        private int totalG;

        /// <summary>
        /// 金币
        /// </summary>
        public int TotalG
        {
            get
            {
                return totalG;
            }
            set
            {
                totalG = value;
                IsolatedStorageSettings.ApplicationSettings[TOTALGKEY] = TotalG;
                IsolatedStorageSettings.ApplicationSettings.Save();
            }
        }

        private SavedGameRecord savedGameRecord;
        /// <summary>
        /// 保存的游戏进度
        /// </summary>
        public SavedGameRecord SavedGameRecord
        {
            get
            {
                return savedGameRecord;
            }
            set
            {
                savedGameRecord = value;
                IsolatedStorageSettings.ApplicationSettings[SAVED_GAME_RECORD] = savedGameRecord;
                IsolatedStorageSettings.ApplicationSettings.Save();
            }
        }

        private void InitToolInfos()
        {
            ToolInfos = new Dictionary<ToolType, ToolInfo>();
            ToolInfos.Add(ToolType.Add500, new ToolInfo()
            {
                CostG = 1500,
                Count = 3,
                Desc = "本次移动内的每次得分都+500",
                Name = "得分+500"
            });
            ToolInfos.Add(ToolType.CollectSprite, new ToolInfo()
            {
                CostG = 3500,
                Count = 3,
                Desc = "收集当前游戏中的所有精神力，增加可用精神力",
                Name = "收集精神力"
            });
            ToolInfos.Add(ToolType.ReArrange, new ToolInfo()
            {
                CostG = 2500,
                Count = 6,
                Desc = "随机重列当前游戏的所有符文",
                Name = "重列"
            });
            ToolInfos.Add(ToolType.ScoreMutil2, new ToolInfo()
            {
                CostG = 4000,
                Count = 3,
                Desc = "本次移动内的所有得分加倍",
                Name = "得分×2"
            });
            ToolInfos.Add(ToolType.CreateNewSpriteRune, new ToolInfo()
            {
                CostG = 3500,
                Count = 3,
                Desc = "随机创造两个带有精神力的符文",
                Name = "创造精神力"
            });
            ToolInfos.Add(ToolType.SpriteMutil2, new ToolInfo()
            {
                CostG = 4000,
                Count = 3,
                Desc = "本次移动内的获得精神力翻倍",
                Name = "精神力×2"
            });
        }

        private void InitStageInfos()
        {
            //初始化关卡信息
            StageInfos = new Dictionary<string, StageInfo>();
            //添加关卡信息
            InitEasyStage();
            InitNormalStage();
            InitHardStage();
        }

        #region 初始化普通关卡

        private void InitHardStage()
        {
            string stageKey = "h_1_1";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 1-1",
                SpriteCount = 15,
                AimScore = 3000
            });
            stageKey = "h_1_2";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 1-2",
                SpriteCount = 15,
                AimScore = 3400
            });
            stageKey = "h_1_3";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 1-3",
                SpriteCount = 15,
                AimScore = 3800
            });
            stageKey = "h_1_4";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 1-4",
                SpriteCount = 15,
                AimScore = 4200
            });
            stageKey = "h_1_5";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 1-5",
                SpriteCount = 15,
                AimScore = 4600
            });

            stageKey = "h_2_1";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 2-1",
                SpriteCount = 17,
                AimScore = 5800
            });
            stageKey = "h_2_2";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 2-2",
                SpriteCount = 17,
                AimScore = 6200
            });
            stageKey = "h_2_3";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 2-3",
                SpriteCount = 17,
                AimScore = 6600
            });
            stageKey = "h_2_4";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 2-4",
                SpriteCount = 17,
                AimScore = 7000
            });
            stageKey = "h_2_5";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 2-5",
                SpriteCount = 17,
                AimScore = 7400
            });

            stageKey = "h_3_1";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 3-1",
                SpriteCount = 19,
                AimScore = 7800
            });
            stageKey = "h_3_2";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 3-2",
                SpriteCount = 19,
                AimScore = 8200
            });
            stageKey = "h_3_3";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 3-3",
                SpriteCount = 19,
                AimScore = 8500
            });
            stageKey = "h_3_4";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 3-4",
                SpriteCount = 19,
                AimScore = 8800
            });
            stageKey = "h_3_5";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 3-5",
                SpriteCount = 19,
                AimScore = 9100
            });

            stageKey = "h_4_1";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 4-1",
                SpriteCount = 21,
                AimScore = 6100
            });
            stageKey = "h_4_2";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 4-2",
                SpriteCount = 21,
                AimScore = 6400
            });
            stageKey = "h_4_3";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 4-3",
                SpriteCount = 21,
                AimScore = 6800
            });
            stageKey = "h_4_4";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 4-4",
                SpriteCount = 21,
                AimScore = 7100
            });
            stageKey = "h_4_5";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 4-5",
                SpriteCount = 21,
                AimScore = 7500
            });

            stageKey = "h_5_1";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 5-1",
                SpriteCount = 23,
                AimScore = 8000
            });
            stageKey = "h_5_2";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 5-2",
                SpriteCount = 23,
                AimScore = 8300
            });
            stageKey = "h_5_3";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 5-3",
                SpriteCount = 23,
                AimScore = 8600
            });
            stageKey = "h_5_4";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 5-4",
                SpriteCount = 23,
                AimScore = 8900
            });
            stageKey = "h_5_5";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 5-5",
                SpriteCount = 23,
                AimScore = 9200
            });

            stageKey = "h_6_1";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 6-1",
                SpriteCount = 25,
                AimScore = 9800
            });
            stageKey = "h_6_2";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 6-2",
                SpriteCount = 25,
                AimScore = 10100
            });
            stageKey = "h_6_3";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 6-3",
                SpriteCount = 25,
                AimScore = 10400
            });
            stageKey = "h_6_4";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 6-4",
                SpriteCount = 25,
                AimScore = 10700
            });
            stageKey = "h_6_5";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 6-5",
                SpriteCount = 25,
                AimScore = 11000
            });

            stageKey = "h_7_1";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 7-1",
                SpriteCount = 27,
                AimScore = 12000
            });
            stageKey = "h_7_2";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 7-2",
                SpriteCount = 27,
                AimScore = 12400
            });
            stageKey = "h_7_3";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 7-3",
                SpriteCount = 27,
                AimScore = 12800
            });
            stageKey = "h_7_4";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 7-4",
                SpriteCount = 27,
                AimScore = 13200
            });
            stageKey = "h_7_5";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 7-5",
                SpriteCount = 27,
                AimScore = 13600
            });

            stageKey = "h_8_1";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 8-1",
                SpriteCount = 29,
                AimScore = 15000
            });
            stageKey = "h_8_2";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 8-2",
                SpriteCount = 29,
                AimScore = 15400
            });
            stageKey = "h_8_3";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 8-3",
                SpriteCount = 29,
                AimScore = 15800
            });
            stageKey = "h_8_4";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 8-4",
                SpriteCount = 29,
                AimScore = 16200
            });
            stageKey = "h_8_5";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 8-5",
                SpriteCount = 29,
                AimScore = 16600
            });

            stageKey = "h_9_1";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 9-1",
                SpriteCount = 31,
                AimScore = 17800
            });
            stageKey = "h_9_2";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 9-2",
                SpriteCount = 31,
                AimScore = 18200
            });
            stageKey = "h_9_3";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 9-3",
                SpriteCount = 31,
                AimScore = 18600
            });
            stageKey = "h_9_4";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 9-4",
                SpriteCount = 31,
                AimScore = 19000
            });
            stageKey = "h_9_5";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 9-5",
                SpriteCount = 31,
                AimScore = 19400
            });

            stageKey = "h_10_1";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 10-1",
                SpriteCount = 33,
                AimScore = 20000
            });
            stageKey = "h_10_2";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 10-2",
                SpriteCount = 33,
                AimScore = 20400
            });
            stageKey = "h_10_3";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 10-3",
                SpriteCount = 33,
                AimScore = 20800
            });
            stageKey = "h_10_4";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 10-4",
                SpriteCount = 33,
                AimScore = 21200
            });
            stageKey = "h_10_5";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 10-5",
                SpriteCount = 33,
                AimScore = 21600
            });
        }
        #endregion

        #region 初始化普通关卡

        private void InitNormalStage()
        {
            string stageKey = "n_1_1";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 1-1",
                SpriteCount = 15,
                AimScore = 1000
            });
            stageKey = "n_1_2";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 1-2",
                SpriteCount = 15,
                AimScore = 1300
            });
            stageKey = "n_1_3";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 1-3",
                SpriteCount = 15,
                AimScore = 1600
            });
            stageKey = "n_1_4";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 1-4",
                SpriteCount = 15,
                AimScore = 1900
            });
            stageKey = "n_1_5";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 1-5",
                SpriteCount = 15,
                AimScore = 2200
            });

            stageKey = "n_2_1";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 2-1",
                SpriteCount = 17,
                AimScore = 2600
            });
            stageKey = "n_2_2";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 2-2",
                SpriteCount = 17,
                AimScore = 2900
            });
            stageKey = "n_2_3";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 2-3",
                SpriteCount = 17,
                AimScore = 3200
            });
            stageKey = "n_2_4";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 2-4",
                SpriteCount = 17,
                AimScore = 3500
            });
            stageKey = "n_2_5";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 2-5",
                SpriteCount = 17,
                AimScore = 3800
            });

            stageKey = "n_3_1";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 3-1",
                SpriteCount = 19,
                AimScore = 4300
            });
            stageKey = "n_3_2";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 3-2",
                SpriteCount = 19,
                AimScore = 4600
            });
            stageKey = "n_3_3";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 3-3",
                SpriteCount = 19,
                AimScore = 4900
            });
            stageKey = "n_3_4";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 3-4",
                SpriteCount = 19,
                AimScore = 5200
            });
            stageKey = "n_3_5";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 3-5",
                SpriteCount = 19,
                AimScore = 5500
            });

            stageKey = "n_4_1";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 4-1",
                SpriteCount = 21,
                AimScore = 6100
            });
            stageKey = "n_4_2";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 4-2",
                SpriteCount = 21,
                AimScore = 6400
            });
            stageKey = "n_4_3";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 4-3",
                SpriteCount = 21,
                AimScore = 6800
            });
            stageKey = "n_4_4";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 4-4",
                SpriteCount = 21,
                AimScore = 7100
            });
            stageKey = "n_4_5";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 4-5",
                SpriteCount = 21,
                AimScore = 7500
            });

            stageKey = "n_5_1";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 5-1",
                SpriteCount = 23,
                AimScore = 8000
            });
            stageKey = "n_5_2";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 5-2",
                SpriteCount = 23,
                AimScore = 8300
            });
            stageKey = "n_5_3";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 5-3",
                SpriteCount = 23,
                AimScore = 8600
            });
            stageKey = "n_5_4";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 5-4",
                SpriteCount = 23,
                AimScore = 8900
            });
            stageKey = "n_5_5";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 5-5",
                SpriteCount = 23,
                AimScore = 9200
            });

            stageKey = "n_6_1";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 6-1",
                SpriteCount = 25,
                AimScore = 9800
            });
            stageKey = "n_6_2";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 6-2",
                SpriteCount = 25,
                AimScore = 10100
            });
            stageKey = "n_6_3";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 6-3",
                SpriteCount = 25,
                AimScore = 10400
            });
            stageKey = "n_6_4";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 6-4",
                SpriteCount = 25,
                AimScore = 10700
            });
            stageKey = "n_6_5";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 6-5",
                SpriteCount = 25,
                AimScore = 11000
            });

            stageKey = "n_7_1";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 7-1",
                SpriteCount = 27,
                AimScore = 12000
            });
            stageKey = "n_7_2";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 7-2",
                SpriteCount = 27,
                AimScore = 12400
            });
            stageKey = "n_7_3";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 7-3",
                SpriteCount = 27,
                AimScore = 12800
            });
            stageKey = "n_7_4";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 7-4",
                SpriteCount = 27,
                AimScore = 13200
            });
            stageKey = "n_7_5";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 7-5",
                SpriteCount = 27,
                AimScore = 13600
            });

            stageKey = "n_8_1";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 8-1",
                SpriteCount = 29,
                AimScore = 15000
            });
            stageKey = "n_8_2";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 8-2",
                SpriteCount = 29,
                AimScore = 15400
            });
            stageKey = "n_8_3";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 8-3",
                SpriteCount = 29,
                AimScore = 15800
            });
            stageKey = "n_8_4";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 8-4",
                SpriteCount = 29,
                AimScore = 16200
            });
            stageKey = "n_8_5";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 8-5",
                SpriteCount = 29,
                AimScore = 16600
            });

            stageKey = "n_9_1";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 9-1",
                SpriteCount = 31,
                AimScore = 17800
            });
            stageKey = "n_9_2";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 9-2",
                SpriteCount = 31,
                AimScore = 18200
            });
            stageKey = "n_9_3";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 9-3",
                SpriteCount = 31,
                AimScore = 18600
            });
            stageKey = "n_9_4";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 9-4",
                SpriteCount = 31,
                AimScore = 19000
            });
            stageKey = "n_9_5";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 9-5",
                SpriteCount = 31,
                AimScore = 19400
            });

            stageKey = "n_10_1";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 10-1",
                SpriteCount = 33,
                AimScore = 20000
            });
            stageKey = "n_10_2";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 10-2",
                SpriteCount = 33,
                AimScore = 20400
            });
            stageKey = "n_10_3";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 10-3",
                SpriteCount = 33,
                AimScore = 20800
            });
            stageKey = "n_10_4";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 10-4",
                SpriteCount = 33,
                AimScore = 21200
            });
            stageKey = "n_10_5";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 10-5",
                SpriteCount = 33,
                AimScore = 21600
            });
        }
        #endregion

        #region 初始化简单关卡

        private void InitEasyStage()
        {
            string stageKey = "e_1_1";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 1-1",
                SpriteCount = 15,
                AimScore = 500
            });
            stageKey = "e_1_2";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 1-2",
                SpriteCount = 15,
                AimScore = 700
            });
            stageKey = "e_1_3";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 1-3",
                SpriteCount = 15,
                AimScore = 900
            });
            stageKey = "e_1_4";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 1-4",
                SpriteCount = 15,
                AimScore = 1100
            });
            stageKey = "e_1_5";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 1-5",
                SpriteCount = 15,
                AimScore = 1300
            });

            stageKey = "e_2_1";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 2-1",
                SpriteCount = 17,
                AimScore = 1500
            });
            stageKey = "e_2_2";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 2-2",
                SpriteCount = 17,
                AimScore = 1700
            });
            stageKey = "e_2_3";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 2-3",
                SpriteCount = 17,
                AimScore = 1900
            });
            stageKey = "e_2_4";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 2-4",
                SpriteCount = 17,
                AimScore = 2100
            });
            stageKey = "e_2_5";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 2-5",
                SpriteCount = 17,
                AimScore = 2300
            });

            stageKey = "e_3_1";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 3-1",
                SpriteCount = 19,
                AimScore = 2500
            });
            stageKey = "e_3_2";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 3-2",
                SpriteCount = 19,
                AimScore = 2700
            });
            stageKey = "e_3_3";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 3-3",
                SpriteCount = 19,
                AimScore = 2900
            });
            stageKey = "e_3_4";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 3-4",
                SpriteCount = 19,
                AimScore = 3100
            });
            stageKey = "e_3_5";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 3-5",
                SpriteCount = 19,
                AimScore = 3300
            });

            stageKey = "e_4_1";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 4-1",
                SpriteCount = 21,
                AimScore = 3500
            });
            stageKey = "e_4_2";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 4-2",
                SpriteCount = 21,
                AimScore = 3700
            });
            stageKey = "e_4_3";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 4-3",
                SpriteCount = 21,
                AimScore = 4000
            });
            stageKey = "e_4_4";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 4-4",
                SpriteCount = 21,
                AimScore = 4200
            });
            stageKey = "e_4_5";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 4-5",
                SpriteCount = 21,
                AimScore = 4400
            });

            stageKey = "e_5_1";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 5-1",
                SpriteCount = 23,
                AimScore = 5000
            });
            stageKey = "e_5_2";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 5-2",
                SpriteCount = 23,
                AimScore = 5200
            });
            stageKey = "e_5_3";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 5-3",
                SpriteCount = 23,
                AimScore = 5400
            });
            stageKey = "e_5_4";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 5-4",
                SpriteCount = 23,
                AimScore = 5600
            });
            stageKey = "e_5_5";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 5-5",
                SpriteCount = 23,
                AimScore = 5800
            });

            stageKey = "e_6_1";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 6-1",
                SpriteCount = 25,
                AimScore = 6500
            });
            stageKey = "e_6_2";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 6-2",
                SpriteCount = 25,
                AimScore = 6700
            });
            stageKey = "e_6_3";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 6-3",
                SpriteCount = 25,
                AimScore = 6900
            });
            stageKey = "e_6_4";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 6-4",
                SpriteCount = 25,
                AimScore = 7100
            });
            stageKey = "e_6_5";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 6-5",
                SpriteCount = 25,
                AimScore = 7300
            });

            stageKey = "e_7_1";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 7-1",
                SpriteCount = 27,
                AimScore = 8000
            });
            stageKey = "e_7_2";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 7-2",
                SpriteCount = 27,
                AimScore = 8200
            });
            stageKey = "e_7_3";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 7-3",
                SpriteCount = 27,
                AimScore = 8400
            });
            stageKey = "e_7_4";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 7-4",
                SpriteCount = 27,
                AimScore = 8600
            });
            stageKey = "e_7_5";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 7-5",
                SpriteCount = 27,
                AimScore = 8800
            });

            stageKey = "e_8_1";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 8-1",
                SpriteCount = 29,
                AimScore = 9500
            });
            stageKey = "e_8_2";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 8-2",
                SpriteCount = 29,
                AimScore = 9700
            });
            stageKey = "e_8_3";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 8-3",
                SpriteCount = 29,
                AimScore = 9900
            });
            stageKey = "e_8_4";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 8-4",
                SpriteCount = 29,
                AimScore = 10100
            });
            stageKey = "e_8_5";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 8-5",
                SpriteCount = 29,
                AimScore = 10300
            });

            stageKey = "e_9_1";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 9-1",
                SpriteCount = 31,
                AimScore = 11000
            });
            stageKey = "e_9_2";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 9-2",
                SpriteCount = 31,
                AimScore = 11200
            });
            stageKey = "e_9_3";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 9-3",
                SpriteCount = 31,
                AimScore = 11400
            });
            stageKey = "e_9_4";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 9-4",
                SpriteCount = 31,
                AimScore = 11600
            });
            stageKey = "e_9_5";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 9-5",
                SpriteCount = 31,
                AimScore = 11800
            });

            stageKey = "e_10_1";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 10-1",
                SpriteCount = 33,
                AimScore = 13000
            });
            stageKey = "e_10_2";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 10-2",
                SpriteCount = 33,
                AimScore = 13200
            });
            stageKey = "e_10_3";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 10-3",
                SpriteCount = 33,
                AimScore = 13400
            });
            stageKey = "e_10_4";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 10-4",
                SpriteCount = 33,
                AimScore = 13600
            });
            stageKey = "e_10_5";
            StageInfos.Add(stageKey, new StageInfo()
            {
                StageKey = stageKey,
                StageName = "STAGE 10-5",
                SpriteCount = 33,
                AimScore = 13800
            });
        }

        #endregion

        public void InitHistoryData()
        {
            if (IsolatedStorageSettings.ApplicationSettings.Contains(LAUNCH_COUNT))
            {
                launchCount = (int)IsolatedStorageSettings.ApplicationSettings[LAUNCH_COUNT];
            }

            if (IsolatedStorageSettings.ApplicationSettings.Contains(MARKET_COMMENT))
            {
                isCommented = (bool)IsolatedStorageSettings.ApplicationSettings[MARKET_COMMENT];
            }

            if (IsolatedStorageSettings.ApplicationSettings.Contains(NEW_USER_TASK_KEY))
            {
                isDoNewUserTask = (bool)IsolatedStorageSettings.ApplicationSettings[NEW_USER_TASK_KEY];
            }

            if (IsolatedStorageSettings.ApplicationSettings.Contains(LAST_STAGE_INDEX_KEY) && IsolatedStorageSettings.ApplicationSettings[LAST_STAGE_INDEX_KEY] != null)
            {
                lastStage = (string)IsolatedStorageSettings.ApplicationSettings[LAST_STAGE_INDEX_KEY];
            }
            if (IsolatedStorageSettings.ApplicationSettings.Contains(IS_PLAY_SOUND_KEY) && IsolatedStorageSettings.ApplicationSettings[IS_PLAY_SOUND_KEY] != null)
            {
                isPlaySound = (bool)IsolatedStorageSettings.ApplicationSettings[IS_PLAY_SOUND_KEY];
            }
            if (IsolatedStorageSettings.ApplicationSettings.Contains(IS_PLAY_BACKGROUND_KEY))
            {
                isPlayBackground = (bool)IsolatedStorageSettings.ApplicationSettings[IS_PLAY_BACKGROUND_KEY];
            }
            if (IsolatedStorageSettings.ApplicationSettings.Contains(TOTALGKEY) && IsolatedStorageSettings.ApplicationSettings[TOTALGKEY] != null)
            {
                totalG = (int)IsolatedStorageSettings.ApplicationSettings[TOTALGKEY];
                //TODO lc 测试使用,发布时去除
                //totalG += 10000000;
            }

            if (IsolatedStorageSettings.ApplicationSettings.Contains(LAST_FULLSCREEN_DATE_KEY))
            {
                lastFullScreenDate = (string)IsolatedStorageSettings.ApplicationSettings[LAST_FULLSCREEN_DATE_KEY];
            }

            if (IsolatedStorageSettings.ApplicationSettings.Contains(GAME_HIGHLIGHTS_KEY) && IsolatedStorageSettings.ApplicationSettings[GAME_HIGHLIGHTS_KEY] != null)
            {
                GameHightlightsRecord = (GameHighlights)IsolatedStorageSettings.ApplicationSettings[GAME_HIGHLIGHTS_KEY];
            }
            else
            {
                GameHightlightsRecord = new GameHighlights();
            }

            if (IsolatedStorageSettings.ApplicationSettings.Contains(SAVED_GAME_RECORD)
                && IsolatedStorageSettings.ApplicationSettings[SAVED_GAME_RECORD] != null)
            {
                savedGameRecord = IsolatedStorageSettings.ApplicationSettings[SAVED_GAME_RECORD] as SavedGameRecord;
            }

            if (IsolatedStorageSettings.ApplicationSettings.Contains(MODE_UNLOCK_STATUS_KEY))
            {
                ModeUnlockStatus = IsolatedStorageSettings.ApplicationSettings[MODE_UNLOCK_STATUS_KEY] as Dictionary<string, bool>;
            }
            else
            {
                // 初始化
                ModeUnlockStatus = new Dictionary<string, bool>();
                ModeUnlockStatus.Add("e", true);
                ModeUnlockStatus.Add("n", false);
                ModeUnlockStatus.Add("h", false);
            }

            if (IsolatedStorageSettings.ApplicationSettings.Contains(STAGE_UNLOCK_STATUS_KEY))
            {
                StageUnlockStatus = IsolatedStorageSettings.ApplicationSettings[STAGE_UNLOCK_STATUS_KEY] as Dictionary<string, bool>;
            }
            else
            {
                // 初始化
                StageUnlockStatus = new Dictionary<string, bool>();
                StageUnlockStatus.Add("e_1", true);
                StageUnlockStatus.Add("n_1", true);
                StageUnlockStatus.Add("h_1", true);
            }


        }

        public void SaveModeUnlockInfo()
        {
            IsolatedStorageSettings.ApplicationSettings[MODE_UNLOCK_STATUS_KEY] = ModeUnlockStatus;
            IsolatedStorageSettings.ApplicationSettings.Save();
        }

        public void SaveStageUnlockInfo()
        {
            IsolatedStorageSettings.ApplicationSettings[STAGE_UNLOCK_STATUS_KEY] = StageUnlockStatus;
            IsolatedStorageSettings.ApplicationSettings.Save();
        }

        #region 游戏记录相关

        public GameHighlights GameHightlightsRecord { get; set; }

        public void SaveGameHightlightsRecord()
        {
            if (GameHightlightsRecord != null)
            {
                IsolatedStorageSettings.ApplicationSettings[GAME_HIGHLIGHTS_KEY] = GameHightlightsRecord;
                IsolatedStorageSettings.ApplicationSettings.Save();
            }
        }

        #endregion
    }
}
